package com.minhang.adsb.service.impl;

import com.minhang.adsb.entity.ServerConfig;
import com.minhang.adsb.service.PushStrategy;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class V3KafkaPushStrategy implements PushStrategy {
    private final KafkaTemplate<String, String> kafkaTemplate;

    public V3KafkaPushStrategy(KafkaTemplate<String, String> kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }

    @Override
    public void push(ServerConfig server, String jsonPayload) {
        kafkaTemplate.send(server.getEndpoint(), jsonPayload); // endpoint存储topic名称
    }
}
